using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerDropManager : Entity_DropManager
{
    private Inventory_Player playerInventory;
    [SerializeField] private float itemLossProbability = 80;

    private void Awake() {
        playerInventory = GetComponent<Inventory_Player>();
    }
    public override void DropItem()
    {
        List<Inventory_Item> itemInventorys = new(playerInventory.itemList);
        List<Inventory_EquipmentSlot> equipmentSlots = new(playerInventory.equipList);

        foreach (var item in itemInventorys)
        {
            if (Random.Range(0, 100) < itemLossProbability)
            {
                CreateDropItem(item.itemData);
                playerInventory.RemoveAllItemInOneSlot(item);
            }
        }
        foreach (var equip in equipmentSlots)
        {
            if (Random.Range(0, 100) < itemLossProbability && equip.HasPlugSlot())
            {
                var equipedItem = equip.equipedItem;

                CreateDropItem(equipedItem.itemData);
                
                playerInventory.UnEquipItem(equipedItem);
                playerInventory.RemoveAllItemInOneSlot(equipedItem);
            }
        }
    }
    
}
